package com.linkedbear.springboot.assemble.a_module.registrar;

import com.linkedbear.springboot.assemble.component.Waiter;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class WaiterRegistrar implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        System.out.println("WaiterRegistrar invoke .......");
        registry.registerBeanDefinition("waiter", new RootBeanDefinition(Waiter.class));
        // 第一个参数是Bean的名称(即id),第二个参数中传入RootBeanDefinition要指定Bean的字节码,相当于向IOC容器注册了普通的单例bean(最终效果与组件扫描,@Bean注解注册的Bean效果相同)
    }
}
